<script setup lang="ts">
import { getCurrentInstance, ref, onMounted } from 'vue'
import { onBeforeRouteLeave } from 'vue-router'
const { proxy } = getCurrentInstance()

/* ---- */
const WXConfig = proxy.$Store.get('WXConfig') || {}
const forFees = proxy.$Fees || []

/* --设置微信分享功能-- */
proxy.$WxTool.loadJsdk(WXConfig, (obj) => {
  if (!obj) return
  // ----
  obj.hideMenuItem()
})

/* ---- */
const items = ref([])

/* ---- */
// --getData--
const getListData = () => {
  setListData(forFees).then((result) => { items.value = result })
}
const setListData = async (items) => {
  const newItems = []
  for (let i = 0; i < Number(items.length); i++) {
    const item = items[i]
    // ----
    if (!item.isOpenUse) continue
    // ----
    newItems.push({
      id: item.id,
      name: item.name
    })
  }
  return newItems
}
// ----
const getAuditFun = (type, item) => {
  switch (Number(type)) {
    case 1: {
      proxy.$Myfun.openPage(proxy, 'push', 'PayRecord', { id: item.id, dealer_id: proxy.$route.query.dealer_id })
      break
    }
  }
}

/* ---- */
onMounted(() => {
  getListData()
})
onBeforeRouteLeave(() => { proxy.$Myfun.setScrollTop(proxy.$refs.formSection) })
</script>

<template>
  <div class="mescroll-touch" ref="formSection">
    <ul class="userSys xw-flex xw-flex-column">
      <li v-for="(item, index) in items">
        <a class="xw-Tfg xw-flex xw-flex-align" @click="getAuditFun(1, item)">
          <div class="USS-title xw-flex-W1">{{item.name}}</div>
          <i class="fal fa-angle-right"></i>
        </a>
      </li>
    </ul>
  </div>
</template>
